<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>丰享悦家</title>
    <link rel="stylesheet" type="text/css" href="../css/base.css">
    <link rel="stylesheet" type="text/css" href="../css/discuss_detail.css">
    <link rel="stylesheet" href="../touchTouch/css/styles.css" />
    <link rel="stylesheet" href="../touchTouch/css/touchTouch.css" />
    <script src="../js/jquery-1.8.3.min.js"></script>
    <script src="../interface/interface.js"></script>
</head>
<body>
<div class="content">
    <div class="header" style="background: #ffffff">
        <p class="title">详情 <i onclick="history.go(-1)" class="titleIonc"></i></p>
    </div>
    <div class="main" style="padding-bottom: 0px;margin-top: 40px ">
        <ul class="goodsparents1">
            <li class="goods_show">
            </li>
        </ul>
    </div>
</div>
<div class="pingIun">
    <p class="pingluntitle">全部回答</p>
    <ul class="goodsparents">

    </ul>
    <div class="load">
        <div class="loader-inner ball-spin-fade-loader">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
</div>
<footer id="footer" ></footer>
<div class="footer">
    <input type="text" id="content" placeholder="分享你的见解">
    <p id="send">发送</p>
</div>
<div class="goTop" style="display:none ">
    <img src="../images/gotop_b.png" alt="">
</div>

<script type="text/javascript" src="../js/config.js"></script>
<script type="text/javascript" src="../js/startmove.js"></script>
<script type="text/javascript" src="../js/zepto.min.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/template.js"></script>
<script type="text/javascript" src="../touchTouch/js/jquery-2.1.4.js"></script>
<script type="text/javascript" src="../touchTouch/js/touchTouch.jquery_xiugai.js"></script>
<script type="text/javascript" src="../js/tmpl/footer.js"></script>
<script>
    var is_login = 0;
    (function(rf){
        var themeid = '';
        var circleid = '';
        var opt = function(){};
        opt.prototype.getDoms = {
            goodsparent : $('.goodsparents'),
            gooddetails : $('.goodsparents1'),
            goTop:$('.goTop'),
            send:$('#send'),
        };
        opt.prototype.getQueryString = function(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r!=null) return r[2]; return '';
        }
        opt.prototype.template = function(data){
            var text = '';
            for(var i=0;i<data.length;i++) {
                text += '<li class="goods_show" style="padding:10px 0px;margin-bottom: 2px"> ' +
                        '<div class="top paddings"> ' +
                        '<div class="img"> ' ;
                        if (data[i]['avatar']==null) {
                            text += '<img src="../images/default_user_portrait.gif" alt=""> ';
                        }else{
                            text += '<img src="'+data[i]["avatar"]+'" />';
                        }
                 text += '</div> ' +
                        '<div class="text"> ' +
                        '<p>'+data[i]['member_name']+'</p> ' +
                        '<p> '+data[i]['reply_addtime']+'</p> ' +
                        '</div> ' +
                        '</div> ' +
                        '<div class="textmiaoshu paddings"> ' +
                        '<p>'+data[i]['reply_content']+'</p> ' +
                        '</div></li>'
            }
//            console.log(text);
            this.getDoms.goodsparent.append(text);
        };
        opt.prototype.template2 = function(data){
            var text = '';
            text += '<li class="goods_show">';
            text += '<div class="top paddings">';
            text += '<div class="img">';
            if (data['avatar']==null) {
                text += '<img src="/data/upload/shop/common/default_user_portrait.gif?0.17620300 1484978714" alt="">';
            }else{
                text += '<img src="'+data["avatar"]+'" />'
            }
            text += '</div>';
            text += '<div class="text">';
            text += '<p>'+data["member_name"]+'</p>';
            text += '<p>'+data["theme_addtime"]+'</p>';
            text += '</div>';
            text += '</div>';
            text += "<a>"
            text += '<div class="textmiaoshu paddings">';
            text += '<p>'+data["wap_content"]+'</p>';
            text += '</div>';
            text += '</a>';
            text += '<div class="thumb paddings" id="thumb">';
            if(data["imags"][0]!=""){
                for(var j=0;j<data["imags"].length;j++){
                    text += '<a href="'+data['imags'][j]+'" style="background: url('+data["imags"][j]+'); background-size: 100% 100%" ></a>';
                }
            }
            text += '</div>';

            text += '<div class="list_footer">';
            text += '<div class="paddings">';
            text += '<p class="look">'+data["theme_browsecount"]+'</p>';
            text += '<p class="good">'+data["theme_commentcount"]+'</p>';
            text += '<p class="pinglun" onclick="drop(this,'+data["theme_id"]+')">'+data["theme_likecount"]+'</p>';
            text += '</div>';
            text += '</div>';
            text += '</li>';
            this.getDoms.gooddetails.html(text);
        }
        $('.goTop').on('click', function () {
            $(document).scrollTop(0);
        })
        $('#send').on('click',function(){

             var content = $('#content').val();
             data = {"c_id":themeid,"content":content,'t_id':circleid};
             if(content==''){
                 creatLayout("你还没填写回复呢");
                 return false;
             }
             opt = {
                 url:"/mobile/index.php?act=circle&op=addComment&c_id="+circleid+"&t_id="+themeid+"&replycontent="+content,
                 type:'GET'
             }
            rf.getData(opt,function(data){
                 console.log(data);
                if(data['code']==200) {
                    $("#content").val("");
                    var data = data['datas']['content'];
                    var text = '';
                    text += '<li class="goods_show" style="padding:10px 0px;margin-bottom: 2px"> ' +
                            '<div class="top paddings"> ' +
                            '<div class="img"> ' ;
                    if (data["member_avatar"]==null) {
                        text += '<img src="../images/default_user_portrait.gif" alt=""> ';
                    }else{
                        text += '<img src="'+data["member_avatar"]+'" />';
                    }
                    text += '</div> ' +
                            '<div class="text"> ' +
                            '<p>'+data['member_name']+'</p> ' +
                            '<p> '+data['reply_addtime']+'</p> ' +
                            '</div> ' +
                            '</div> ' +
                            '<div class="textmiaoshu paddings"> ' +
                            '<p>'+data['reply_content']+'</p> ' +
                            '</div></li>';
                    var goodsparents = document.getElementsByClassName('goodsparents')[0];
                    goodsparents.innerHTML = text + goodsparents.innerHTML;
                }
            })
        })
        opt.prototype.init = function(){
            var index = 1;
            var _slef = this;
            var c_id = _slef.getQueryString('cid');
            var t_id = _slef.getQueryString('t_id');
            opt = {
                url:"/mobile/index.php?act=circle&op=theme&c_id="+c_id+"&t_id="+t_id,
                type:'GET',
            }
            rf.getData(opt,function(data){
//                console.log(data);
                is_login = data['datas']['is_login'];
                var reply = data['datas']['reply'];
                var Theme = data['datas']['theme'];
                themeid = Theme['theme_id'];
                circleid = Theme['circle_id'];
                if (data['code']==200){
                    _slef.template2(Theme);
                    if(reply==''){
                         document.getElementsByClassName('goodsparents')[0].innerHTML = "<div class='noData'>暂无评论</div>";
                         document.getElementsByClassName('load')[0].style.display = 'none';
                    }
                    _slef.template(reply);
                    document.getElementsByClassName('load')[0].style.display = 'none';

                }
                if(data['datas']['code'] == 400){
                    window.location.href=WapSiteUrl+'/tmpl/member/login.html';
                }
            })
            $(document).on('scroll',function(){
                $(document).scrollTop()>10?$(".goTop").fadeIn():$(".goTop").fadeOut();
                if($(document).scrollTop()>(((93*5)*index)-($(window).height()))){
                    index++;
                    opt = {
                        url:"/mobile/index.php?act=circle&op=theme&c_id="+c_id+"&t_id="+t_id+"&page="+index,
                        type:'GET',
                    }
                    document.getElementsByClassName('load')[0].style.display = 'block';
//                    console.log(opt)
                    rf.getData(opt,function(data){
                          if(data['datas']['reply']==''){
                              document.getElementsByClassName('load')[0].innerHTML = "--我是有底线的--";
                              return;
                          }
                          _slef.template(data['datas']['reply']);

                    })
                }
            });
        }
        var i = new opt();
        i.init();

    })(window)

    function drop(_this,t_id){
        if(!is_login){
            creatLayout("请先登录");
            return;
        }
       var url = "/mobile/index.php?act=circle&op=ajax_likeyes&t_id="+t_id;
        $.ajax({
            type:"GET",
            url:url,
            dataType:"json",
            success:function(res){
                 if(res){
                      creatLayout("点赞成功");
                      _this.innerHTML = parseInt(_this.innerHTML)+1;
                 }else{
                      creatLayout("你已经点赞成功");
                 }
            }
        })
    }

    $('.thumb a').touchTouch();
</script>
</body>
</html>